package com.prs.crm.action.cqunicom;

import java.util.Collection;

import org.apache.struts2.convention.annotation.Action;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.courser.ui.TreeNode;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.domain.hr.Role;
import com.prs.crm.domain.sys.Menu;
import com.prs.crm.domain.sys.Module;
import com.prs.crm.service.hr.RoleService;
import com.prs.crm.service.sys.MenuService;

/**
 * @author LanXiaoGang
 * @E-mail:lan9liang@163.com
 * @qq:7857553326
 * @version 创建时间：2011-4-7 下午02:07:09
 * 简单说明
 */

public class LmitsAllotAction extends BaseAction {

	private Collection<Module> modules;

	private Collection<Menu> menus;

	private Collection<TreeNode> nodes;

	private Integer[] roleIds;

	private String menuId;

	private String uncheckId;

	private String moduleId;

	private Menu menu;

	private MenuService menuService;
	private Role role;

	private RoleService roleService;
	
	private PaginationSupport pagination;
	
	
	
	@Action("listAllot")
	public String execute() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				Role.class);
		criteria.add(Restrictions.gt("id",7));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getRoleService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	
	@Action("editAllot")
	public String edit() {
		return SUCCESS;
	}
	@Action("listRootAllot")
	public String listRootAllot() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				Menu.class);
		criteria.add(Restrictions.eq("text", "首页"));
		criteria.add(Restrictions.isNull("parent"));
		criteria.addOrder(Order.asc("sequence"));
		pagination = getPaginationHelper().prepare(pagination);
		this.setPagination(this.getRoleService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	@Action(value = "loadChildTreeAllot")
	public String loadChildTreeAllot() {
		return SUCCESS;
	}
	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public RoleService getRoleService() {
		return roleService;
	}

	public void setRoleService(RoleService roleService) {
		this.roleService = roleService;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	public Collection<Module> getModules() {
		return modules;
	}

	public void setModules(Collection<Module> modules) {
		this.modules = modules;
	}

	public Collection<Menu> getMenus() {
		return menus;
	}

	public void setMenus(Collection<Menu> menus) {
		this.menus = menus;
	}

	public Collection<TreeNode> getNodes() {
		return nodes;
	}

	public void setNodes(Collection<TreeNode> nodes) {
		this.nodes = nodes;
	}

	public Integer[] getRoleIds() {
		return roleIds;
	}

	public void setRoleIds(Integer[] roleIds) {
		this.roleIds = roleIds;
	}

	public String getMenuId() {
		return menuId;
	}

	public void setMenuId(String menuId) {
		this.menuId = menuId;
	}

	public String getUncheckId() {
		return uncheckId;
	}

	public void setUncheckId(String uncheckId) {
		this.uncheckId = uncheckId;
	}

	public String getModuleId() {
		return moduleId;
	}

	public void setModuleId(String moduleId) {
		this.moduleId = moduleId;
	}

	public Menu getMenu() {
		return menu;
	}

	public void setMenu(Menu menu) {
		this.menu = menu;
	}

	public MenuService getMenuService() {
		return menuService;
	}

	public void setMenuService(MenuService menuService) {
		this.menuService = menuService;
	}
	
	
}
